package com.example.myapplication.until;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.myapplication.R;
import com.example.myapplication.model.TUnit;
import com.example.myapplication.model.TUser;

import java.util.List;

/**
 * 作者：Administrator on 2019/10/16 0016 14:02
 * 邮箱：1415862429@qq.com
 */
public class Adapter_User extends BaseAdapter {
    private Context context;
    private List<TUser> list;

    //private Province data;
    //布局加载器
    private LayoutInflater inflater;

    public Adapter_User(Context context, List<TUser> list) {
        this.context = context;
        this.list = list;
        //获取系统服务
        inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        view=inflater.inflate(R.layout.list_item,null);

        TextView tv1=view.findViewById(R.id.userid);
        TextView tv2=view.findViewById(R.id.name);
        TextView tv3=view.findViewById(R.id.phone);
        TextView tv4=view.findViewById(R.id.gender);
        TextView tv5=view.findViewById(R.id.classid);


        tv1.setText( list.get(i).getUserid() );
        tv2.setText(list.get(i).getName());
        tv3.setText( list.get(i).getPhone() );
        tv4.setText(list.get(i).getGender());
        tv5.setText( list.get(i).getClassid() );


        return view;
    }
}
